package edu.cqie.smartfarm.verify.validation;

import edu.cqie.smartfarm.constant.UserConstant;
import edu.cqie.smartfarm.verify.anno.Status;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class StatusValidation implements ConstraintValidator<Status, Integer> {
    /**
     *
     * @param status 将来要校验的数据
     * @param constraintValidatorContext
     * @return
     */
    @Override
    public boolean isValid(Integer status, ConstraintValidatorContext constraintValidatorContext) {
        // 校验
        if (status == null || (status == UserConstant.USER_STATUS_DISABLE || status == UserConstant.USER_STATUS_NORMAL)){
            return true;
        }
        return false;
    }
}
